package ch9sorting;

import java.util.Arrays;
import java.util.Comparator;

class AnagramComparator implements Comparator<String> {

	@Override
	public int compare(String o1, String o2) {
		char[] a1 = o1.toCharArray();
		Arrays.sort(a1);
		char[] a2 = o2.toCharArray();
		Arrays.sort(a2);
		return (new String(a1)).compareTo(new String(a2));
	}
	
}

public class Ex2 {

	public static void main(String ...strings) {
		String [] ss = new String [] {"abc", "acc", "cba"};
		Arrays.sort(ss, new AnagramComparator());
		int a =0;
	}
}
